package com.huawei.hwid.core.helper.handler;

import android.content.Context;
import android.os.Bundle;
import com.huawei.hwid.core.b.a.b;
import com.huawei.hwid.core.d.l;
import com.huawei.hwid.core.encrypt.e;
import java.util.ArrayList;

public class a {
    protected Context b;

    public a(Context context) {
        this.b = context;
    }

    public ArrayList<Integer> c(Bundle bundle) {
        ArrayList<Integer> integerArrayList = bundle.getIntegerArrayList("UIHandlerErrCodeList");
        if (integerArrayList == null) {
            return new ArrayList();
        }
        return integerArrayList;
    }

    public boolean d(Bundle bundle) {
        return bundle.getBoolean("isUIHandlerAllErrCode");
    }

    public void a(Bundle bundle) {
    }

    public void b(Bundle bundle) {
    }

    public void e(Bundle bundle) {
        try {
            int i = bundle.getInt("responseCode");
            int i2 = bundle.getInt("resultCode");
            int a = b.a(bundle, bundle.getInt("errorCode"));
            String string = bundle.getString("errorDesc");
            Bundle bundle2;
            if (3000 == i) {
                bundle2 = new Bundle();
                bundle2.putParcelable("requestError", new ErrorStatus(4099, "token invalid"));
                b(bundle2);
            } else if (200 == i || d(bundle)) {
                ArrayList c = c(bundle);
                if (i2 == 0 || c.contains(Integer.valueOf(a)) || d(bundle)) {
                    Bundle bundle3 = new Bundle();
                    if (i2 == 0) {
                        a(bundle);
                        return;
                    }
                    bundle3.putParcelable("requestError", new ErrorStatus(a, string));
                    bundle3.putBoolean("isRequestSuccess", true);
                    b(bundle3);
                    return;
                }
                bundle2 = new Bundle();
                bundle2.putParcelable("requestError", new ErrorStatus(a, e.a(string)));
                b(bundle2);
            } else {
                String str = "";
                if (i == 307) {
                    i2 = 70001104;
                }
                com.huawei.hwid.core.d.b.e.b("RequestCallback", "network is unavailable, code = ", true);
                String a2 = a(i, i2);
                Bundle bundle4 = new Bundle();
                bundle4.putParcelable("requestError", new ErrorStatus(i, a2));
                b(bundle4);
            }
        } catch (Throwable th) {
            com.huawei.hwid.core.d.b.e.d("RequestCallback", "Throwable", true);
        }
    }

    private String a(int i, int i2) {
        int a;
        if (1007 == i) {
            a = l.a(this.b, "CS_network_connect_error");
        } else {
            a = l.a(this.b, "CS_ERR_for_cannot_conn_service");
        }
        return this.b.getString(a);
    }
}
